package com.ossean;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Set;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.ossean.dao.DBDest;
import com.ossean.dao.DBSource;
import com.ossean.dao.GatherDao;
import com.ossean.util.StringHandler;

@Component
public class TestDate {
	Logger logger = Logger.getLogger(this.getClass());
	@Resource
	private DBSource dbSource;
	@Resource
	private  GatherDao gatherDao;
	@Resource
	private  DBDest dbDest;
	
	public void start(){
		String timeStr  = gatherDao.selectMaxExtractedTime("gather_projects");//
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date myDate2=null;
		try {
			myDate2 = dateFormat.parse(timeStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		System.out.println(timeStr);
		System.out.println(myDate2.toString());
		//System.out.println(dbDest.selectOpenSourceProjectsIds("gather_projects_test").size());
//		System.out.println(a.toString());
//		System.out.println(b);
//		System.out.println(a.after(b));
	}
	
	public void start_test(){
//		String homepage = "http://github.com/apache/abdera;http://incubator.apache.org/abdera/";
//		String homepage1 = "http://incubator.apache.org/abdera/";
//			String arr[] = homepage1.split(";");
//			System.out.println(arr.length);
//			for(String a : arr){
//				System.out.println(a);
//			}
		Set<Integer> set = dbDest.selectOpenSourceProjectsIds("gather_projects_test");
		System.out.println(set.size());
		
		
		
	}
	public static void main(String[] args) {
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/applicationContext*.xml");
		TestDate Main = applicationContext.getBean(TestDate.class);
		Main.start_test();
//		StringBuilder a = new StringBuilder(",");
//		String b = StringHandler.removeFirstEndComma(a.toString());
//		System.out.println(b);
//		String relation = ",123,34,34,5,6,7,5,7,";
//		System.out.println(StringHandler.removeDupIdInStr(relation));

	}

}
